package com.njust.utils;

import lombok.Data;

@Data
public class Paging {

    /**
     * 手动进行分页工具
     */

        private Integer totalNum;//总条数
        private Integer totalPage;//总页数
        private Integer pageSize;//每页条数
        private Integer page;//当前页码
        private Integer queryIndex;//当前页从第几条开始查

        public static Paging pagination(Integer totalNum, Integer pageSize, Integer page){
            Paging pageInfo = new Paging();
            pageInfo.setTotalNum(totalNum);
            Integer totalPage = totalNum % pageSize == 0 ? totalNum / pageSize : totalNum / pageSize + 1;
            pageInfo.setTotalPage(totalPage);
            pageInfo.setPage(page);
            pageInfo.setPageSize(pageSize);
            pageInfo.setQueryIndex(pageSize *(page-1));
            return pageInfo;
        }

    }

